package asionreachel.cn.smarthomedemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import asionreachel.cn.smarthomedemo.R;
import asionreachel.cn.smarthomedemo.base.BaseActivity;


/**
 * Created by SuperMa on 2017/6/26.
 */

public class SelectModeActivity extends BaseActivity {
    public static final int s_iRequestCodeSmartConfig = 0;
    public static final int s_iRequestCodeApConfig = 1;
    public static final int s_iRequestCodeScanConfig = 2;

    @Override
    protected void onCreate( Bundle savedInstanceState ) {
        super.onCreate(savedInstanceState);

        setContentView( R.layout.activity_setting_mode );

        ImageView ivBack = (ImageView)findViewById(R.id.iv_back);
        LinearLayout lyOneKey = (LinearLayout)findViewById(R.id.ly_onekey);
        LinearLayout lyAp  = (LinearLayout)findViewById(R.id.ly_ap);
        LinearLayout lyScan = (LinearLayout)findViewById(R.id.ly_scan);

        ivBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBack();
            }
        });
        lyOneKey.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onSettingOneKey();
            }
        });
        lyAp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onSettingWifi();
            }
        });
        lyScan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onSettingScan();
            }
        });
    }

    public void onBack() {
        finish();
    }

    @Override
    public void onBackKey() {
        onBack();
    }

    @Override
    protected void onActivityResult( int requestCode, int resultCode, Intent data ) {
        if( s_iRequestCodeSmartConfig == requestCode ) {
            if( RESULT_OK != resultCode ) {
                return;
            }

            finish();
        }
        else if( s_iRequestCodeApConfig == requestCode ) {
            if( RESULT_OK != resultCode ) {
                return;
            }

            finish();
        }
        else if( s_iRequestCodeScanConfig == requestCode ) {
            if( RESULT_OK != resultCode ) {
                return;
            }

            finish();
        }
    }

    //一键配置
    public void onSettingOneKey()
    {
        Intent intent = new Intent( mActivity , OneKeyActivity.class);
        mActivity.startActivityForResult( intent, s_iRequestCodeSmartConfig );
    }

    //热点配置
    public void onSettingWifi()
    {
        Intent intent = new Intent( mActivity, SelectWifiActivity.class);
        mActivity.startActivityForResult( intent, s_iRequestCodeApConfig );
    }

    // 扫码配置
    public void onSettingScan()
    {
//        Intent intent = new Intent( mActivity, ScanActivity.class);
//        mActivity.startActivityForResult( intent, s_iRequestCodeScanConfig );
    }
}
